package com.yhm.net.simpleBIO服务端对客户端连接阻塞;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.net.ServerSocket;
import java.net.Socket;

public class BIOServer {
  public static void main(String[] args) {
    ServerSocket serverSocket = null;
    try {
      serverSocket = new ServerSocket(8080);
    } catch (IOException e) {
      e.printStackTrace();
    }
    while(true) {

      try {

        Socket socket = serverSocket.accept();
        InputStream inputStream = socket.getInputStream();
        BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(inputStream));
        String str = null;
        while ((str = bufferedReader.readLine()) != null) {
          System.out.println("客户端连接发送过来的数据：" + str);
        }
        bufferedReader.close();
        socket.close();

      } catch (IOException e) {
        e.printStackTrace();
      }
    }


  }
}
